import { useEffect, RefObject } from "react";
import { FadeInAnimation } from "../Welcome/animation";

function useFadeIn(ref: RefObject<HTMLHeadingElement>, duration: number) {
  useEffect(() => {
    const animation = new FadeInAnimation(ref.current);
    animation.start(duration);

    return () => {
      animation.stop();
    };
  }, [duration, ref]);
}

export default useFadeIn;
